package o;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class avc extends FilterInputStream {
    private int ʻ;
    private int[] ˊ = new int[this.ॱ];
    private long[] ˋ = new long[4];
    private long[] ˎ = new long[4];
    private short ˏ;
    private final int ॱ;
    private int ॱॱ = this.ॱ;

    public avc(InputStream inputStream, int i, int i2, short s, int i3, int i4) throws IOException {
        super(inputStream);
        this.ॱ = Math.min(Math.max(s, 4), 8);
        this.ˎ = ave.ˊ(i ^ i4, this.ॱ ^ i4);
        this.ˋ = ave.ˊ(i2 ^ i4, i3 ^ i4);
        this.ʻ = this.in.read();
    }

    public int read() throws IOException {
        ˎ();
        int[] iArr = this.ˊ;
        int i = this.ॱॱ;
        this.ॱॱ = i + 1;
        return iArr[i];
    }

    public int read(byte[] bArr, int i, int i2) throws IOException {
        if (i2 == 0) {
            return 0;
        }
        int read = read();
        if (read == -1) {
            return -1;
        }
        bArr[i] = (byte) read;
        read = 1;
        while (read < i2) {
            int read2 = read();
            if (read2 == -1) {
                return read;
            }
            bArr[i + read] = (byte) read2;
            read++;
        }
        return read;
    }

    public long skip(long j) throws IOException {
        long j2 = 0;
        while (j2 < j && read() != -1) {
            j2++;
        }
        return j2;
    }

    public int available() throws IOException {
        return this.ॱ - this.ॱॱ;
    }

    public boolean markSupported() {
        return false;
    }

    private void ˊ() {
        ave.ˊ(this.ˎ, this.ˋ, this.ˏ);
        for (int i = 0; i < this.ॱ; i++) {
            int[] iArr = this.ˊ;
            iArr[i] = (int) (((long) iArr[i]) ^ ((this.ˎ[this.ˏ] >> (i << 3)) & 255));
        }
        this.ˏ = (short) ((this.ˏ + 1) % 4);
    }

    private void ˎ() throws IOException {
        if (this.ॱॱ != this.ॱ) {
            return;
        }
        if (this.ʻ == -1) {
            Arrays.fill(this.ˊ, -1);
            this.ॱॱ = 0;
            return;
        }
        this.ˊ[0] = this.ʻ;
        for (int i = 1; i < this.ॱ; i++) {
            this.ˊ[i] = this.in.read();
        }
        ˊ();
        this.ʻ = this.in.read();
        if (this.ʻ == -1) {
            Arrays.fill(this.ˊ, this.ॱ - this.ˊ[this.ॱ - 1], this.ॱ, -1);
        }
        this.ॱॱ = 0;
    }
}
